#include "JPVec2.h"

#include <math.h>

const JPVec2 JPVec2::vecX = JPVec3(1.0f,0.0f);
const JPVec2 JPVec2::vecY = JPVec3(0.0f,1.0f);

float JPVec2::dot(const JPVec2 &v) const
{
	return (x*v.x)+(y*v.y);
}

/*
* returns the cross product between this and v
*/

float JPVec2::cross(const JPVec2 &v) const
{
	return (x*v.y) - (y * v.x);
}

/*
* returns the length of the vector
*/
float JPVec2::magnitude() const
{
	return sqrtf(x*x+y*y);
}

/*
* returns the sqr length ofthis vector
*/
float JPVec2::sqrMagnitude() const
{
	return x*x+y*y;
}

/*
* Normalises this vector to have length 1
*/
void JPVec2::normalise()
{
	(*this)/=magnitude();
}

/*
* returns a normalised version of this vector
*/
JPVec2 JPVec2::getNormalised() const
{
	return (*this)/magnitude();
}